/*
 * @Author: czy
 * @Date: 2021-04-29 14:25:59
 * @LastEditTime: 2021-07-13 19:08:58
 */
#include "string.h"

#include "sys/system.h"
#include "sys/syscall.h"

#include "stdlib.h"
#include "stdio.h"

/**
 * @description: Exit.
 * @param status	Exit code, default for 0.
 */
void exit(int status)
{
	_syscall(PROCESSEND, 0, 0);
}

/**
 * @description: Start shell.
 */
void shell(void)
{
	_syscall(STARTSHELL, 0, 0);
}

/**
 * @description: Get the environment variable (the value is a string).
 * @param name  Name.
 * @return Value.
 */
char *env(char *name)
{
	return (char *)(_syscall(GETENV, (int)name, 0));
}

/**
 * @description: Set the environment variable (the value is a string).
 * @param name  Name.
 * @param value Value.
 */
void exports(char *name, char *value)
{
	_syscall(SETENV, (int)name, (int)value);
}

/**
 * @description: Scheduled task.
 * @param func		Callback function.
 * @param interval	Interval time.
 * @param times		-1 is pointing repeatedly, 1 is pointing once.
 */
void cron(void (*func)(void), int interval, int times)
{
	if (times < 0)
	{
		_syscall(TIMER, (int)func, interval);
	}
	else if (times == 1)
	{
		_syscall(SETTIMEOUT, (int)func, interval);
	}
}